package com.test.license;


import com.test.Protection.Constant;

/**
 * @author: zouren
 * @date: 2022/3/10
 * @description:
 */
public class LCheckThread  extends Thread {
    private long periods = 86400000L;
    boolean cancelled = false;

    public LCheckThread(int hours) {
        this.periods = (long)(hours * 60 * 60) * 1000L;
//        this.periods = (long)(hours) * 1000L;
        this.setDaemon(true);
        this.setName(Constant.T_CHECK_THREAD);
    }

    public LCheckThread() {
        this.setDaemon(true);
    }

    public void cancel() {
        this.cancelled = true;
    }

    @Override
    public void run() {
        while(!this.cancelled) {
            try {
                LCheck.getInstance().check(true);
                Thread.sleep(this.periods);
            } catch (Exception e) {
                Constant.error(e);
            }
        }

    }
}
